import { reactive, ref } from 'vue'
import { defineStore } from "pinia";


export const useUserInfo = defineStore('userInfo', () => {
    let user = ref(new UserInfo)
    let loginInfo = {
        username: '',
        password: '',
    }
    const SETUSER = (v: UserInfo): void => {
        user.value = v
        console.log(loginInfo, 'loginInfo');
    }
    return { user, SETUSER, loginInfo }
}, {
    persist: {
        paths: ['user']
    }
})

class UserInfo {
    avatarUrl?: string
    gmtCreate: number
    gmtLastLogin: string
    gmtUpdate: number
    id: number
    lastLoginIp: string
    perms: string[]
    phone: string
    realname: string
    roleIds: number[]
    roles: string[]
    status: number
    username: string
    constructor() {
        this.avatarUrl = ''
        this.gmtCreate = 0;
        this.gmtLastLogin = ''
        this.gmtUpdate = 0
        this.id = 0
        this.lastLoginIp = ''
        this.perms = []
        this.phone = ''
        this.realname = ''
        this.roleIds = []
        this.roles = []
        this.status = 0
        this.username = ''
    }
}